<?php
if(!empty($_POST['contact_name']) && !empty($_POST['contact_surname']) && !empty($_POST['contact_email']) && !empty($_POST['contact_phone']) && !empty($_POST['contact_subject']) && !empty($_POST['contact_msg']))
{
	$to = 'info@condominiossabana.com';
	$subject = $_POST['contact_subject'];

	$mail = '<strong>'.$_POST['contact_name'].'</strong><br />'.$_POST['contact_surname'].'<br />'.$_POST['contact_phone'].'<br />';
	$mail .= '<hr /><p>'.nl2br($_POST['contact_msg']).'</p>';

	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
	$headers .= 'From: '.$_POST['contact_name'].' <'.$_POST['contact_email'].">\r\n";
	$headers .= 'Reply-To: '.$_POST['contact_name'].' <'.$_POST['contact_email'].">\r\n";

	if(mail($to,$subject,$mail,$headers))
	{
		$dataJSON['success'] = true;
	}
	else
	{
		$dataJSON['error'] = 'Ha ocurrido un error: no se pudo enviar el correo.';
	}
}
else
{
	$dataJSON['error'] = 'Ha ocurrido un error: debes rellenar todos los campos.';
}

echo json_encode($dataJSON);
?>